<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateClassesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('classes', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('academic_year')->default(0)->index('classes_academic_year_index')->comment('学年');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `classes` comment '班级表'");

        Schema::create('students', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('class_id');
            $table->string('name', 40);
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `students` comment '学生表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('classes');
        Schema::dropIfExists('students');
    }
}
